var namecardlistId=document.URL.split("=")[1];
var namecardlistName=null;


var vm = new Vue({
    el:"#addNameList",
    data:{
        nameCardList:'',
    },
    // 方法存放区
    methods: {

        getAllNameCardListInfo() {
            axios({
                method: 'POST',
                url: 'http://localhost:8099/personalNameCard/getAllNameCardList',
            }).then(function (result) {
                vm.nameCardList = result.data;
                // console.log(vm.nameCardList)
            }).catch(function (reason) {
                console.log(reason);
            })
        },


    },

    //页面加载完自动执行
    mounted(){
        this.getAllNameCardListInfo();
    }

})



function submit() {

    nameCardListName=$(".aa>li:nth-child(1)>select>option:checked").attr("power");
    // console.log(nameCardListName);
    // console.log(namecardlistId);


    if(nameCardListName===undefined){
        alert("请先选择")
    }else {
        //判断该名片夹分类中是否有这个名片
        axios({
            method: 'POST',
            url: 'http://localhost:8099/personalNameCard/nameCardListYZ',
            data:{
                "namecardlistName":nameCardListName,
                "namecardlistNamecardId":namecardlistId,
            }
        }).then(function (result) {
            if(result.data){
                alert("该分类中已有该名片");
            }else {
                //移动（即增加一条新分类的该名片记录和修改之前该名片所在分类的记录的状态）
                // alert("aa")
                axios({
                    method: 'POST',
                    url: 'http://localhost:8099/personalNameCard/nameCardListRemove',
                    data:{
                        "namecardlistName":nameCardListName,
                        "namecardlistNamecardId":namecardlistId,
                    }
                }).then(function (result) {
                    if(result.data){
                        alert("移动成功");
                        location.href="personalNameCardList.html"
                    }else {
                        alert("移动失败");
                    }
                }).catch(function (reason) {
                    console.log(reason);
                })
            }
        }).catch(function (reason) {
            console.log(reason);
        })

    }


}